<?php
$_CfgMenu = array (
		0 => array (
				'icon' => 'admin',
				'menuText' => '系统管理',
				'link' => './index.php?menu_no_top=eim',
				'subMenu' => array (
						0 => array (
								'icon' => 'companyinfo',
								'menuText' => '公司信息',
								'link' => 'index.php?uniqcode=GEN&menu_no_top=eim' 
						),
						1 => array (
								'icon' => 'companyinfo',
								'menuText' => '公司办公地点',
								'link' => 'index.php?uniqcode=LOC&menu_no_top=eim' 
						),
						2 => array (
								'icon' => 'companyinfo',
								'menuText' => '公司组织架构',
								'link' => 'index.php?uniqcode=CST&menu_no_top=eim' 
						),
						3 => array (
								'icon' => 'job',
								'menuText' => '职位',
								'link' => '#',
								'subMenu' => array (
										0 => array (
												'icon' => 'job',
												'menuText' => '工作职位',
												'link' => 'index.php?uniqcode=JOB&menu_no_top=eim' 
										),
										1 => array (
												'icon' => 'job',
												'menuText' => '职位要求',
												'link' => 'index.php?uniqcode=SPC&menu_no_top=eim' 
										),
										2 => array (
												'icon' => 'job',
												'menuText' => '雇佣状态',
												'link' => 'index.php?uniqcode=EST&menu_no_top=eim' 
										) 
								) 
						),
						4 => array (
								'icon' => 'customfields',
								'menuText' => '基本字典',
								'link' => '#',
								'subMenu' => array (
										0 => array (
												'icon' => 'natandrace',
												'menuText' => '国籍',
												'link' => 'index.php?uniqcode=NAT&menu_no_top=eim' 
										),
										1 => array (
												'icon' => 'natandrace',
												'menuText' => '民族',
												'link' => 'index.php?uniqcode=ETH&menu_no_top=eim' 
										),
										2 => array (
												'icon' => 'skills',
												'menuText' => '时薪标准',
												'link' => 'index.php?uniqcode=DAY_SAL&menu_no_top=eim' 
										),
										3 => array (
												'icon' => 'skills',
												'menuText' => '等级津贴',
												'link' => 'index.php?uniqcode=ADM_EXM&menu_no_top=eim' 
										),
										4 => array (
												'icon' => 'skills',
												'menuText' => '技能',
												'link' => 'index.php?uniqcode=SKI&menu_no_top=eim' 
										),
										5 => array (
												'icon' => 'skills',
												'menuText' => '技能津贴',
												'link' => 'index.php?uniqcode=SKI_ALW&menu_no_top=eim' 
										),
										6 => array (
												'icon' => 'qualifications',
												'menuText' => '相关证书',
												'link' => 'index.php?uniqcode=LIC&menu_no_top=eim' 
										),
										7 => array (
												'icon' => 'qualifications',
												'menuText' => '学历',
												'link' => 'index.php?uniqcode=EDU&menu_no_top=eim' 
										),
										8 => array (
												'icon' => 'skills',
												'menuText' => '语言能力',
												'link' => 'index.php?uniqcode=LAN&menu_no_top=eim' 
										),
										9 => array (
												'icon' => 'customfields',
												'menuText' => '自定义字典',
												'link' => 'index.php?uniqcode=CTM&menu_no_top=eim' 
										) 
								) 
						),
						5 => array (
								'icon' => 'user',
								'menuText' => '账号管理',
								'link' => '#&menu_no_top=eim',
								'subMenu' => array (
										0 => array (
												'icon' => 'user',
												'menuText' => '账号列表',
												'link' => 'lib/controllers/CentralController.php?ctrl=user&menu_no_top=eim' 
										),
										1 => array (
												'icon' => 'user',
												'menuText' => '添加账号',
												'link' => 'lib/controllers/CentralController.php?ctrl=user&menu_no_top=eim&action=addShow' 
										) 
								) 
						),
						6 => array (
								'icon' => 'memberships',
								'menuText' => '系统设置',
								'link' => '#',
								'subMenu' => array (
										0 => array (
												'icon' => 'memberships',
												'menuText' => '全局参数设置',
												'link' => 'lib/controllers/CentralController.php?uniqcode=GlobalParams&menu_no_top=eim' 
										) 
								) 
						) 
				) 
		),
		1 => array (
				'icon' => 'pim',
				'menuText' => '人事系统',
				'link' => './index.php?menu_no_top=hr',
				'subMenu' => array (
						0 => array (
								'icon' => 'emplist',
								'menuText' => '员工列表',
								'link' => './lib/controllers/CentralController.php?reqcode=EMP&VIEW=MAIN&sortField=0&sortOrder0=ASC' 
						),
						1 => array (
								'icon' => 'empadd',
								'menuText' => '添加员工',
								'link' => './lib/controllers/CentralController.php?reqcode=EMP&capturemode=addmode' 
						),
						2 => array (
								'icon' => 'emplist',
								'menuText' => '员工合同管理',
								'link' => './lib/controllers/CentralController.php?reqcode=EMPContract&VIEW=MAIN&sortField=0&sortOrder0=ASC' 
						),
						3 => array (
								'icon' => 'emplist',
								'menuText' => '员工行政管理',
								'link' => '#',
								'subMenu' => array (
										0 => array (
												'icon' => 'emplist',
												'menuText' => '奖惩记录',
												'link' => 'lib/controllers/CentralController.php?reqcode=BonusPenalty' 
										),
										1 => array (
												'icon' => 'emplist',
												'menuText' => '调薪记录',
												'link' => 'lib/controllers/CentralController.php?reqcode=SalaryAdjustments' 
										),
										2 => array (
												'icon' => 'emplist',
												'menuText' => '社保记录',
												'link' => 'lib/controllers/CentralController.php?reqcode=SocialSecurity' 
										),
										3 => array (
												'icon' => 'emplist',
												'menuText' => '积假管理',
												'link' => 'lib/controllers/CentralController.php?reqcode=AnnualLeave' 
										) 
								) 
						),
						4 => array (
								'icon' => 'emplist',
								'menuText' => '员工后勤记录',
								'link' => '#',
								'subMenu' => array (
										0 => array (
												'icon' => 'emplist',
												'menuText' => '领取物品记录',
												'link' => 'lib/controllers/CentralController.php?reqcode=ReceiveGoods' 
										),
										1 => array (
												'icon' => 'emplist',
												'menuText' => '培训记录',
												'link' => 'lib/controllers/CentralController.php?reqcode=TrainRecord' 
										),
										2 => array (
												'icon' => 'emplist',
												'menuText' => '宿舍安排记录',
												'link' => 'lib/controllers/CentralController.php?reqcode=Dormitory' 
										) 
								) 
						) 
				) 
		),
		2 => array (
				'icon' => 'attendance',
				'menuText' => '考勤系统',
				'link' => './index.php?menu_no_top=attendance',
				'subMenu' => array (
						0 => array (
								'icon' => 'daysoff',
								'menuText' => '定义公休日',
								'link' => '#',
								'subMenu' => array (
										0 => array (
												'icon' => 'daysoff',
												'menuText' => '周末',
												'link' => 'lib/controllers/CentralController.php?leavecode=Leave&action=Holiday_Weekend_List' 
										),
										1 => array (
												'icon' => 'daysoff',
												'menuText' => '特定节日',
												'link' => 'lib/controllers/CentralController.php?leavecode=Leave&action=Holiday_Specific_List' 
										) 
								) 
						),
						1 => array (
								'icon' => 'skills',
								'menuText' => '考勤规则',
								'link' => './lib/controllers/CentralController.php?adcode=attendrule' 
						),
						2 => array (
								'icon' => 'emplist',
								'menuText' => '导入考勤',
								'link' => './lib/controllers/CentralController.php?adcode=ExcelUpload' 
						),
						3 => array (
								'icon' => 'emplist',
								'menuText' => '考勤原始记录',
								'link' => './lib/controllers/CentralController.php?adcode=attend_original' 
						),
						4 => array (
								'icon' => 'emplist',
								'menuText' => '考勤记录汇总',
								'link' => './lib/controllers/CentralController.php?adcode=attend_effectual_lun' 
						),
						5 => array (
								'icon' => 'emplist',
								'menuText' => '考勤报表',
								'link' => '#',
								'subMenu' => array (
										0 => array (
												'icon' => 'emplist',
												'menuText' => '月度考勤',
												'link' => 'lib/controllers/CentralController.php?adcode=report&action=Month' 
										),
										1 => array (
												'icon' => 'emplist',
												'menuText' => '季度考勤',
												'link' => 'lib/controllers/CentralController.php?adcode=report&action=Quarter' 
										),
										2 => array (
												'icon' => 'emplist',
												'menuText' => '年度考勤',
												'link' => 'lib/controllers/CentralController.php?adcode=report&action=Year' 
										) 
								) 
						),
						6 => array (
								'icon' => 'emplist',
								'menuText' => '考勤白名单',
								'link' => './lib/controllers/CentralController.php?adcode=whitelist' 
						),
						7 => array (
								'icon' => 'emplist',
								'menuText' => '特殊考勤',
								'link' => '#',
								'subMenu' => array (
										0 => array (
												'icon' => 'emplist',
												'menuText' => '请假',
												'link' => 'lib/controllers/CentralController.php?adcode=special_attend' 
										),
										1 => array (
												'icon' => 'emplist',
												'menuText' => '加班',
												'link' => 'lib/controllers/CentralController.php?adcode=special_attend&typeid=9' 
										),
										2 => array (
												'icon' => 'emplist',
												'menuText' => '临换',
												'link' => 'lib/controllers/CentralController.php?adcode=special_attend&typeid=7' 
										),
										3 => array (
												'icon' => 'emplist',
												'menuText' => '迟退旷',
												'link' => 'lib/controllers/CentralController.php?adcode=special_attend&typeid=12' 
										),
										4 => array (
												'icon' => 'emplist',
												'menuText' => '外勤',
												'link' => 'lib/controllers/CentralController.php?adcode=special_attend&typeid=8' 
										),
										5 => array (
												'icon' => 'emplist',
												'menuText' => '漏打卡',
												'link' => 'lib/controllers/CentralController.php?adcode=special_attend&typeid=13' 
										) 
								) 
						),
						8 => array (
								'icon' => 'emplist',
								'menuText' => '自助服务',
								'link' => './lib/controllers/CentralController.php?adcode=report&action=My' 
						) 
				) 
		),
		3 => array (
				'icon' => 'time',
				'menuText' => '排班系统',
				'link' => './index.php?menu_no_top=arg_class',
				'subMenu' => array (
						0 => array (
								'icon' => 'skills',
								'menuText' => '班制定义',
								'link' => './lib/controllers/CentralController.php?argcode=defineclass' 
						),
						1 => array (
								'icon' => 'skills',
								'menuText' => '人员编班',
								'link' => './lib/controllers/CentralController.php?argcode=workgroup&action=View_Work_Groups' 
						),
						2 => array (
								'icon' => 'skills',
								'menuText' => '工作排班',
								'link' => './lib/controllers/CentralController.php?argcode=argclass&action=View_Class_Arg' 
						),
						3 => array (
								'icon' => 'skills',
								'menuText' => '人员排班表',
								'link' => './lib/controllers/CentralController.php?argcode=argclass&action=View_Class_Members' 
						),
						4 => array (
								'icon' => 'skills',
								'menuText' => '排班调整',
								'link' => './lib/controllers/CentralController.php?argcode=argclass&action=View_Class_Adjust' 
						) 
				) 
		),
		4 => array (
				'icon' => 'time',
				'menuText' => '薪资系统',
				'link' => './index.php?menu_no_top=salary',
				'subMenu' => array (
						0 => array (
								'icon' => 'skills',
								'menuText' => '薪资规则',
								'link' => './lib/controllers/CentralController.php?salcode=salaryrule' 
						),
						1 => array (
								'icon' => 'emplist',
								'menuText' => '员工工资档案',
								'link' => './lib/controllers/CentralController.php?salcode=salaryemp' 
						),
						2 => array (
								'icon' => 'emplist',
								'menuText' => '月度考勤',
								'link' => './lib/controllers/CentralController.php?salcode=salary_attendance&VIEW=MAIN&sortField=0&sortOrder0=ASC' 
						),
						3 => array (
								'icon' => 'emplist',
								'menuText' => '奖罚历史记录',
								'link' => './lib/controllers/CentralController.php?salcode=BonusPenalty&VIEW=MAIN&sortField=0&sortOrder0=ASC' 
						),
						4 => array (
								'icon' => 'emplist',
								'menuText' => '调薪历史记录',
								'link' => './lib/controllers/CentralController.php?salcode=SalaryAdjustments&VIEW=MAIN&sortField=0&sortOrder0=ASC' 
						),
						5 => array (
								'icon' => 'emplist',
								'menuText' => '月度工资预算表',
								'link' => './lib/controllers/CentralController.php?salcode=budget&VIEW=MAIN&sortField=0&sortOrder0=ASC' 
						),
						6 => array (
								'icon' => 'emplist',
								'menuText' => '工资条',
								'link' => './lib/controllers/CentralController.php?salcode=salarypaper&VIEW=MAIN&sortField=0&sortOrder0=ASC' 
						) 
				) 
		),
		5 => array (
				'icon' => 'oa',
				'menuText' => 'OA管理',
				'link' => './index.php?menu_no_top=oa',
				'subMenu' => array (
						0 => array (
								'icon' => 'skills',
								'menuText' => '首页公告',
								'link' => './lib/controllers/CentralController.php?oacode=oamange&action=news' 
						),
						1 => array (
								'icon' => 'emplist',
								'menuText' => 'TO DO List',
								'link' => './lib/controllers/CentralController.php?oacode=oamange&action=todo' 
						),
						2 => array (
								'icon' => 'emplist',
								'menuText' => '加班审批',
								'link' => './lib/controllers/CentralController.php?oacode=oamange&action=attend&TypeId=9' 
						),
						3 => array (
								'icon' => 'emplist',
								'menuText' => '临换审批',
								'link' => './lib/controllers/CentralController.php?oacode=oamange&action=attend&TypeId=7' 
						),
						4 => array (
								'icon' => 'emplist',
								'menuText' => '请假审批',
								'link' => './lib/controllers/CentralController.php?oacode=oamange&action=attend&TypeId=0' 
						),
						5 => array (
								'icon' => 'emplist',
								'menuText' => '年假审批',
								'link' => './lib/controllers/CentralController.php?oacode=oamange&action=attend&TypeId=3' 
						),
						6 => array (
								'icon' => 'emplist',
								'menuText' => '迟退旷审批',
								'link' => './lib/controllers/CentralController.php?oacode=oamange&action=attend&TypeId=12' 
						),
						7 => array (
								'icon' => 'emplist',
								'menuText' => '外勤审批',
								'link' => './lib/controllers/CentralController.php?oacode=oamange&action=attend&TypeId=8' 
						),
						8 => array (
								'icon' => 'emplist',
								'menuText' => '漏打卡审批',
								'link' => './lib/controllers/CentralController.php?oacode=oamange&action=attend&TypeId=13' 
						),
						9 => array (
								'icon' => 'emplist',
								'menuText' => '自定义OA审批',
								'link' => './lib/controllers/CentralController.php?oacode=oamange&action=def' 
						),
						10 => array (
								'icon' => 'definereports',
								'menuText' => '自定义OA单',
								'link' => './lib/controllers/CentralController.php?oacode=oamange&action=show' 
						) 
				) 
		),
		6 => array (
				'icon' => 'power',
				'menuText' => '权限管理',
				'link' => './index.php?menu_no_top=power',
				'subMenu' => array (
						0 => array (
								'icon' => 'power',
								'menuText' => '权限编辑',
								'link' => './lib/controllers/CentralController.php?ctrl=power' 
						),
						1 => array (
								'icon' => 'power',
								'menuText' => '添加权限组',
								'link' => './lib/controllers/CentralController.php?ctrl=power&action=addShow' 
						),
						2 => array (
								'icon' => 'power',
								'menuText' => '受权给员工',
								'link' => './lib/controllers/CentralController.php?ctrl=power&action=giveUserPower' 
						) 
				) 
		),
		7 => array (
				'icon' => 'report',
				'menuText' => '报表',
				'link' => './index.php?menu_no_top=rep',
				'subMenu' => array (
						0 => array (
								'icon' => 'viewreports',
								'menuText' => '查看报表',
								'link' => 'index.php?repcode=EMPVIEW&menu_no_top=rep' 
						),
						1 => array (
								'icon' => 'definereports',
								'menuText' => '定义报表',
								'link' => 'index.php?repcode=EMPDEF&menu_no_top=rep' 
						) 
				) 
		) 
);
$_CfgBase = array (
		'eim' => array (
				'name' => '系统管理',
				'icon' => 'eim',
				'num' => 1,
				'subMenu' => array () 
		) 
);
$num = 1;
function buildMenu($data = array(), $n = 1) {
	$return = array ();
	$kNum = $n+1;
	foreach ( $data as $kr => $rv ) {
		$tmp ['icon'] = $rv ['icon'];
		$tmp ['name'] = $rv ['menuText'];
		$tmp ['num'] =$kNum;
		$params = array ();
		if (!preg_match ( '/\#/', $rv ['link'] )) { 
			$link = explode ( "?", $rv ['link'] );
			$paramStrs = explode ( "&", $link [1] );
			foreach ( $paramStrs as $kp => $vp ) {
				$keyVal = explode ( "=", $vp );
				if ($keyVal [0] == 'menu_no_top'||$keyVal [0] == 'sortField'||$keyVal [0] == 'sortOrder0') {
					continue;
				}
				
				
				$params [$keyVal [0]] = trim ( $keyVal [1] );
			}
		}
		$tmp['params']=$params;
		$tmp ['url'] = $rv ['link'];
		$return [$kNum] = $tmp;
		if (isset ( $rv ['subMenu'] ) && ! empty ( $rv ['subMenu'] )) {
			$return [$kNum] ['subMenu'] = buildMenu ( $rv ['subMenu'], $kNum*100 );
		}
		$kNum++;
	}
	
	return $return;
}
$return=array();
foreach ( $_CfgMenu as $kr => $rv ) {
	$kr=$kr+1;
	$tmp ['icon'] = $rv ['icon'];
	$tmp ['name'] = $rv ['menuText'];
	$tmp ['num'] = $num;
	$params = array ();
	if (!preg_match ( '/\#/', $rv ['link'] )) {
		$link = explode ( "?", $rv ['link'] );
		$paramStrs = explode ( "&", $link [1] );
		foreach ( $paramStrs as $kp => $vp ) {
			$keyVal = explode ( "=", $vp );
			if ($keyVal [0] == 'menu_no_top') {
				continue;
			}
			$params [$keyVal [0]] = trim ( $keyVal [1] );
		}
	}
	$tmp['params']=$params;
	$tmp ['url'] = $rv ['link'];
	$return [$rv ['icon']] = $tmp;
	if (isset ( $rv ['subMenu'] ) && ! empty ( $rv ['subMenu'] )) {
		$return [$rv ['icon']] ['subMenu'] = buildMenu ( $rv ['subMenu'], $num*100 );
	}
	$num++;
}
// var_export ( $_CfgBase );
var_export ( $return );